From 930e7c4bb2f0eb3b497b2db25b5a745d387fa0dd Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 20 Mar 2008 18:28:52 +0000 Subject: [PATCH] ioemu: Fix vnc buffer sharing when linesize != width * depth. Signed-off-by: Stefano Stabellini --- tools/ioemu/vnc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/ioemu/vnc.c b/tools/ioemu/vnc.c index c7ab7ebcdb..9c9cbb3fc0 100644 --- a/tools/ioemu/vnc.c +++ b/tools/ioemu/vnc.c @@ -370,16 +370,20 @@ static void vnc_dpy_resize(DisplayState *ds, int w, int h, int linesize) int o; if (!ds->shared_buf) { + ds->linesize = w * vs->depth; if (allocated) - ds->data = realloc(ds->data, h * linesize); + ds->data = realloc(ds->data, h * ds->linesize); else - ds->data = malloc(h * linesize); + ds->data = malloc(h * ds->linesize); allocated = 1; - } else if (allocated) { - free(ds->data); - allocated = 0; + } else { + ds->linesize = linesize; + if (allocated) { + free(ds->data); + allocated = 0; + } } - vs->old_data = realloc(vs->old_data, h * linesize); + vs->old_data = realloc(vs->old_data, h * ds->linesize); vs->dirty_row = realloc(vs->dirty_row, h * sizeof(vs->dirty_row[0])); vs->update_row = realloc(vs->update_row, h * sizeof(vs->dirty_row[0])); @@ -396,7 +400,6 @@ static void vnc_dpy_resize(DisplayState *ds, int w, int h, int linesize) size_changed = ds->width != w || ds->height != h; ds->width = w; ds->height = h; - ds->linesize = linesize; if (vs->csock != -1 && vs->has_resize && size_changed) { vs->width = ds->width; vs->height = ds->height; -- 2.30.2